import time
def index(x,y):
    time.sleep(3)
    print('index %s %s'%(x,y))

def wrapper():
    star = time.time()
    index(111,222)
    stop = time.time()
    print(stop - star)

wrapper()


def index(x,y,z):
    time.sleep(3)
    print('index %s %s %s'%(x,y,z))

def wrapper(*args,**kwargs):
    star = time.time()
    index(*args,**kwargs)
    stop = time.time()
    print(stop - star)

wrapper(3333,4444,5555)



def index(x,y,z):
    time.sleep(3)
    print('index %s %s %s' % (x, y, z))

def outter(func):
    #func=index
    def wrapper(*args,**kwargs):
        start = time.time()
        func(*args,**kwargs)
        stop=time.time()
        print(stop-start)
    return wrapper
f=outter(index)
f(111,222,[333,444,555])




def index(x,y,z):
    time.sleep(3)
    print('index %s %s %s' % (x, y, z))

def home(name):
    time.sleep(2)
    print('welcome %s to home page'%name)

def outter(func):
    #func=index
    def wrapper(*args,**kwargs):
        start = time.time()
        func(*args,**kwargs)
        stop=time.time()
        print(stop-start)
    return wrapper
f=outter(index)
f(111,222,[333,444,555])
f1=outter(home)
f1('Tom')

def home(name):
    time.sleep(2)
    print('welcome %s to home page'%name)
    return 123

def outter(func):
    def wrapper(*args,**kwargs):
        start=time.time()
        func(*args,**kwargs)
        stop=time.time()
        print(stop-start)

    return wrapper
#调用home时，home指向的时wrapper的内存地址
hom=outter(home)
res=hom('engo')#res=wrapper('engo')
print('返回值',res)


def home(name):
    time.sleep(2)
    print('welcome %s to home page' % name)
    return 123


def outter(func):
    def wrapper(*args, **kwargs):
        start = time.time()
        res=func(*args, **kwargs)#函数的返回值
        stop = time.time()
        print(stop - start)
        return res
    return wrapper


# 调用home时，home指向的时wrapper的内存地址
hom = outter(home)
res = hom('engo')  # res=wrapper('engo')
print('返回值', res)

























